package cn.com.headfree.mouldshow.dao.impl;

import cn.com.headfree.entity.TContestInfoTemp;
import cn.com.headfree.mouldshow.dao.TContestInfoTempDao;
import com.gta.edu.sdk.base.dao.impl.BaseDaoImpl;
import org.springframework.stereotype.Repository;

import java.sql.Timestamp;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Repository("/tContestInfoTempDao")
public class TContestInfoTempDaoImpl extends BaseDaoImpl<TContestInfoTemp> implements TContestInfoTempDao {


    @Override
    public void saveInfo(TContestInfoTemp tContestInfo) {
        String sql = "insert into t_contest_info_temp (id,erp_no,user_name,id_card_no,award_date,comp_name,host_org,award_name,award_level,comp_rank,get_title,org_id,creater_id,creater_name,create_time,updater_id,updater_name,update_time,del_sign,is_valid,audit_state,orignal_id,business_type_id,primitive_id) values ";
        StringBuilder sqlBuilder = new StringBuilder(sql);
        sqlBuilder.append("(#{id,jdbcType=VARCHAR},").append("#{erp_no,jdbcType=VARCHAR},").append("#{user_name,jdbcType=VARCHAR},")
                .append("#{id_card_no,jdbcType=VARCHAR},").append("#{award_date,jdbcType=DATE},")
                .append("#{comp_name,jdbcType=VARCHAR},").append("#{host_org,jdbcType=VARCHAR},").append("#{award_name,jdbcType=VARCHAR},")
                .append("#{award_level,jdbcType=VARCHAR},").append("#{comp_rank,jdbcType=VARCHAR},")
                .append("#{get_title,jdbcType=VARCHAR},").append("#{org_id,jdbcType=VARCHAR},").append("#{creater_id,jdbcType=VARCHAR},")
                .append("#{creater_name,jdbcType=VARCHAR},").append("#{create_time,jdbcType=DATE},")
                .append("#{updater_id,jdbcType=VARCHAR},").append("#{updater_name,jdbcType=VARCHAR},")
                .append("#{update_time,jdbcType=DATE},").append("#{del_sign,jdbcType=INTEGER},")
                .append("#{is_valid,jdbcType=INTEGER},").append("#{audit_state,jdbcType=INTEGER},")
                .append("#{orignal_id,jdbcType=VARCHAR},").append("#{business_type_id,jdbcType=VARCHAR},")
                .append("#{primitive_id,jdbcType=VARCHAR})");
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("id", tContestInfo.getId());
        params.put("erp_no", tContestInfo.getErpNo());
        params.put("user_name", tContestInfo.getUserName());
        params.put("id_card_no", tContestInfo.getIdCardNo());
        params.put("award_date", tContestInfo.getAwardDate());
        params.put("comp_name", tContestInfo.getCompName());
        params.put("host_org", tContestInfo.getHostOrg());
        params.put("award_name", tContestInfo.getAwardName());
        params.put("award_level", tContestInfo.getAwardLevel());
        params.put("comp_rank", tContestInfo.getCompRank());
        params.put("get_title", tContestInfo.getGetTitle());
        params.put("org_id", tContestInfo.getOrgId());
        params.put("creater_id", tContestInfo.getCreaterId());
        params.put("creater_name", tContestInfo.getCreaterName());
        params.put("create_time", new Timestamp(new Date().getTime()));
        params.put("updater_id", tContestInfo.getUpdaterId());
        params.put("updater_name", tContestInfo.getUpdaterName());
        params.put("update_time", new Timestamp(new Date().getTime()));
        params.put("del_sign", 0);
        params.put("is_valid", tContestInfo.getIsValid());
        params.put("audit_state", tContestInfo.getAuditState());
        params.put("orignal_id", tContestInfo.getOrignalId());
        params.put("business_type_id", tContestInfo.getBusinessTypeId());
        params.put("primitive_id", tContestInfo.getPrimitiveId());
        this.executeSql(sqlBuilder.toString(), params);
    }
}
